#pragma once

#include <vector>
#include "graphics/Texture.h"
#include "GameComponent.h"
#include "beziercurve.h"
#include "carmanager.h"
#include "helicopter.h"

static unsigned int NextGameObjectID;


#define TickDiffInSec(a, b) (double)abs(double(a-b)/1000.)

typedef std::vector<CGameComponent*>::iterator GameObjectPtr;

class CGameManager
{
protected:
	double _timePassed; //total time passed in seconds
	long _lastTickCount; //the last system tick count
	double _parsingTime; //if we build an intersection system, this can be used
						//to drive the clock into smaller intervals for analysis
	double _deltaTime; //this will hold the current difference between frames in seconds

	CTexture _desertFloor;
	float _flength, _fwidth;
    CTexture _base;
    float _blength, _bwidth;

	//car dealios
	CCarManager _cars;
	CHelicopter *_heli;

	//add things to this array to have them updated and drawn
	std::vector<CGameComponent*> _objects;


	void UpdateTimeValues();
	void DrawFloor();

public:
	CGameManager(void);
	virtual ~CGameManager(void);

	//some accessors
	double getTimePassed() { return _timePassed; }
	long getLastTickCount() { return _lastTickCount; }
	double DeltaTime() { return _deltaTime; }

	virtual void Update();
	virtual void Render();
	virtual void Initialize();
	virtual void AddObject(CGameComponent *gc);
	virtual bool RemoveObject(unsigned int ID);
	virtual void setPlayer(CHelicopter *heli) { _heli = heli; }
	void CheckCollision(CHelicopter* heli);
};
